<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    protected function getReqArray($content){
        return (array)json_decode($content);
    }

    protected function getTime(){
        return date("Y-m-d H:i:s");
    }

    protected function getMsg($code,$msg){

        $res =array();

        $res['code'] = $code;

        $res['msg'] = $msg;

        return $res;
    }

    protected function getData($code,$resData){
        $res =array();

        $res['code'] = $code;

        $res['data'] = $resData;

        return $res;
    }

    protected function getRes($res,$act){
        $resArr = array();

        $msg ="";
        $code ="";
        switch($act){
            case "add":
                $msg = "添加";
                break;
            case "del":
                $msg = "删除";
                break;
            case "update":
                $msg = "更新";
                break;
            case "login":
                $msg = "登陆";
                break;
        }
        if($res>0){
            $code =1;
            $msg .= "成功";
        }
        else{
            $code = 2;
            $msg .= "失败";
        }
        $resArr['code'] = $code;
        $resArr['msg'] = $msg;

        return $resArr;
    }
}
